package org.opens.guava.utilites.eventBus.listeners;

import com.google.common.eventbus.Subscribe;
import org.opens.guava.utilites.eventBus.base.Apple;
import org.opens.guava.utilites.eventBus.base.Fruit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class EatFruitListener {

    private final static Logger LOGGER = LoggerFactory.getLogger(EatFruitListener.class);

    /**
     * 注意:
     *      1. 事件方法必须使public和void的.
     *      2. 只能有一个参数.
     *      3. 必须有@Subscribe注解.
     * @param event
     */
    @Subscribe
    public void eatFuit(Fruit event) {
        LOGGER.info("eat Fruit: {}", event);
    }

    @Subscribe
    public void eatFuit(Apple event) {
        LOGGER.info("eat Apple: {}", event);
    }

}
